/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.gui.controlador;

import Shared.ListObjCarZona;
import Shared.ServMain;
import java.rmi.Naming;
import java.util.ArrayList;
//import Shared.MatrizInterseccionSalida;

/**
 *
 * @author ed
 */
public class GestorConexionLectura {

    private static GestorConexionLectura instance;

    public static GestorConexionLectura getInstance() {
        if (instance == null) {
            instance = new GestorConexionLectura();
        }
        return instance;
    }

    public static Propiedades properties = Propiedades.getInstance();

    public void iniSimIntersecciones() {
//        ServMain servMain;
//        try {
//            servMain = (ServMain) Naming.lookup(properties.getProperties().getProperty("PATH_SERVLECT"));
////            servMain.iniProcesamiento();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }

    public ListObjCarZona getListCarZona(int xPos, int yPos) {
        ServMain servMain;
        ListObjCarZona aux = null;
        try {
            servMain = (ServMain) Naming.lookup(properties.getProperties().getProperty("PATH_SERVLECT"));
            aux = servMain.getlistCarrosPorZona(xPos, yPos);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return aux;
    }

    public double getVelocidadPromedio() {
        double retorno = 0;
        ServMain servMain;
        try {
            servMain = (ServMain) Naming.lookup(properties.getProperties().getProperty("PATH_SERVLECT"));
            retorno = servMain.getVelocidadPromedio();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return retorno;
    }

    public ListObjCarZona getlistCarrosPorZona(int x, int y) {
        ListObjCarZona retorno = new ListObjCarZona();
        ServMain servMain;
        try {
            servMain = (ServMain) Naming.lookup(properties.getProperties().getProperty("PATH_SERVLECT"));
            retorno = servMain.getlistCarrosPorZona(x, y);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return retorno;
    }

    public ArrayList<ListObjCarZona> getlistCarrosTotal() {
        ArrayList<ListObjCarZona> retorno = new ArrayList<>();
        ServMain servMain;
        try {
            servMain = (ServMain) Naming.lookup(properties.getProperties().getProperty("PATH_SERVLECT"));
            retorno = servMain.getlistCarrosTotal();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return retorno;
    }

}
